package com.yunxi.service.localService.dealer.impl;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.dao.dealer.PartnerMapper;
import com.yunxi.dealer.pojo.ExportPartnerVO;
import com.yunxi.dealer.pojo.ExportPartnerVOUps;
import com.yunxi.dealer.pojo.PartnerVO;
import com.yunxi.model.dealer.Partner;
import com.yunxi.service.localService.dealer.PartnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 渠道商信息 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-13
 */
@Service
public class PartnerServiceImpl extends ServiceImplPlus<PartnerMapper, Partner> implements PartnerService {

   @Autowired
   PartnerMapper partnerMapper;

   @Override
   public PartnerVO load(String partnerCode,String tenantId) {
     return partnerMapper.load(partnerCode,tenantId);
   }

   @Override
   public PartnerVO getCasById(String partnerId) {
      return partnerMapper.getCasById(partnerId);
   }

   @Override
   public PartnerVO getByUserCode(String userCode) {
      Map map = new HashMap();
      map.put("userCode",userCode);
      return partnerMapper.getByUserCode(map);
   }

   @Override
   public List listSel(PartnerVO v) {
      return partnerMapper.listSel(v);
   }

   @Override
   public PageInfo pageSel(PartnerVO v, Integer pageNum, Integer pageSize) {
      PageHelperPlus.startPage(pageNum,pageSize);
      List<Object> list = baseMapper.listSel(v);
      PageInfo<Object> pageInfo = new PageInfo<Object>(list);
      return pageInfo;
   }

   @Override
   public ApiResult listByAreaCode(PartnerVO partnerVO, Integer pageNum, Integer pageSize) {
      PageHelperPlus.startPage(pageNum,pageSize);
      List<PartnerVO> partnerVOList = baseMapper.listByAreaCode(partnerVO);
      PageInfo<PartnerVO> partnerVOPageInfo = new PageInfo<>(partnerVOList);
      return ResponseUtil.ok(partnerVOPageInfo);
   }

   @Override
   public List<PartnerVO> listByAreaCodes(PartnerVO partnerVO) {
      List<PartnerVO> partnerVOList = baseMapper.listByAreaCode(partnerVO);
      return partnerVOList;
   }

   @Override
   public String leastPartner(String clueType, String province,String vehicleCode,String city) {
      return baseMapper.leastPartner(clueType,province,vehicleCode,city);


   }

   @Override
   public PartnerVO getByPartnerCode(String partnerCode) {
      return baseMapper.getByPartnerCode(partnerCode);
   }

   @Override
   public PartnerVO getByBusinessCode(String s) {
      return baseMapper.getByBusinessCode(s);
   }

   @Override
   public List<PartnerVO> listByProductAuth(String partnerCode, String productTypeCode) {

      return baseMapper.listByProductAuth(partnerCode,productTypeCode);
   }

   @Override
   public String getPartnerType(String partnerCode) {
      return baseMapper.getPartnerType(partnerCode);

   }

   @Override
   public String getAccountGroupCode(String financeInstitutionCode) {

      return baseMapper.getAccountGroupCode(financeInstitutionCode);
   }

   @Override
   public String getPartnerCodeByPartnerName(String partnerName) {
      return baseMapper.getPartnerCodeByPartnerName(partnerName);
   }

    @Override
    public List<ExportPartnerVO> exportPartnerPMS(PartnerVO partnerVO) {
      return baseMapper.exportPartnerPMS(partnerVO);
    }

   @Override
   public List<ExportPartnerVOUps> exportPartnerUPS(PartnerVO partnerVO) {
      return baseMapper.exportPartnerUPS(partnerVO);
   }
}
